<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    {js href='/public/static/jquery/jquery-1.11.0.min.js' /}
    {js href='/public/static/layui/layui.js' /}
    {CSS href="/public/static/layui/css/layui.css" /}
    {CSS href="__ADDONSTATIC__/css/style.css" /}
    {js href='__STATIC__/zclip/jquery.zclip.min.js' /}
</head>
<body>
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title">
        <a href="{:addonUrl('index',['type'=>1])}"><li {if condition='$type == 1'} class="layui-this"{/if}>基础设置</li></a>
        <a href="{:addonUrl('index',['type'=>2])}"><li {if condition='$type == 2'} class="layui-this"{/if}>首页轮播图</li></a>
    </ul>
    {if condition='$type == 1'}
    <div class="layui-tab-content">
        <div class="forms-content">
            <form name="form2" class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">微网站名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" value="{$form.name}" required lay-verify="required" placeholder="请输入名称" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">微网站链接地址</label>
                    <div class="layui-input-block">
                        <input type="text"  value="{$form.url}" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    {elseif condition='$type == 2'}
    <div class="layui-tab-content">
        <div>
            <a href="{:addonUrl('addSlider')}"  class="layui-btn layui-btn-normal layui-btn-sm rha-nav-title">增加轮播</a>
        </div>
        <form class="layui-form" action="">
            <table class="layui-table">
                <colgroup>
                    <col width="120">
                    <col>
                    <col width="250">
                    <col width="90">
                    <col width="60">
                    <col width="200">
                </colgroup>
                <thead>
                <tr>
                    <th>图片</th>
                    <th>描述</th>
                    <th>外链地址</th>
                    <th>显示状态</th>
                    <th>排序</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="slider_list" id="v" }
                <tr>
                    <td><a href="{$v.img_path}" target="_blank" ><img src="{$v.img_path}" alt="" width="90" height="60" ></a></td>
                    <td>{$v.describe}</td>
                    <td>{$v.url}</td>
                    <td> <form  class="layui-form" action=""><input type="checkbox" data-id="{$v.id}" lay-filter="showSlider" {if condition="$v.show == 1"}checked{/if} lay-skin="switch" name="show"/></form></td>
                    <td>{$v.sort}</td>
                    <td>
                        <a class="rha-bt-a copyUrls"  href="javascript:;" >复制连接</a>
                        <div style="display: none" class="copyUrl">{$v.url}</div>
                        <a class="rha-bt-a" href="{:addonUrl('editSlider',['id'=>$v.id])}">编辑</a>
                        <a class="rha-bt-a" onclick="delForms('{$v.id}')" href="javascript:;">删除</a>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
        </form>
    </div>

    {/if}
</div>
<script>

    function delForms(id) {
        parent.layer.confirm('确定删除吗？', {
            btn: ['是','不'], //按钮
            offset: ['20%', '30%'],
            shade: 0.1,
        }, function(){
            $.post("{:addonUrl('delSlider')}",{fid:id},function (res) {
                if(res.status==1){
                    parent.layer.alert(res.msg,function (index) {
                        window.location.reload();
                        parent.layer.close(index);
                    })

                }else{
                    parent.layer.alert(res.msg)
                }
            })
        }, function(){

        });
    }
    $(function () {
        $('.copyUrls').zclip({
            path: '__STATIC__/zclip/ZeroClipboard.swf',
            copy: function(){
                parent.layer.msg("复制成功");
                return $(this).next('.copyUrl').text();
            },
            afterCopy: function(){

            }
        });
    })
    layui.use(['form', 'layer'], function () {
        var form = layui.form;
        var layer = layui.layer;

        form.on('submit(formDemo)', function (data) {
            var loadIndex = layer.load(1);
            $.post('', data.field, function (res) {
                layer.close(loadIndex);
                parent.layer.msg(res.msg);
            }).error(function (error) {
                parent.layer.alert('500 Internal Server Error');
                parent.layer.close(loadIndex)
            })
            return false;
        });
        form.on('switch(showSlider)', function(data){
            var show = 0;
            if($(data.elem).prop("checked")) {
                show = 1;
            }
            var id = $(data.elem).attr('data-id');
            $.post("{:addonUrl('showSlider')}",{fid:id,show:show},function (res) {

            });
            form.render('checkbox');
        });
    });
</script>
</body>
</html>